<?php
header("Content-type:text/html; charset=utf-8;");
require '../../../ppf/fun.php';
require '../../../ppf/pdo_mysql.php';
require '../../../ppf/Filter.php';
date_default_timezone_set("PRC");
$pd=new pdo_mysql();
$filter=new Filter();
session_start();

$submitMethod=$_SERVER["REQUEST_METHOD"];
if($submitMethod=='POST'){
    $now=date('Y-m-d H:i:s',time());
	$sender       = empty($_POST['uid'])?"":$_POST['uid'];
	//$acceptname   = empty($_POST['acceptname'])?0:Filter::filter_html($_POST['acceptname']);
	$accept_id   = empty($_POST['accept_id'])?0:Filter::filter_html($_POST['accept_id']);
    $content      = empty($_POST['content'])?"":$_POST['content'];
	$geter_id = explode(',',$accept_id);
	for($i=0;$i<count($geter_id);$i++){
		$in_data=array(
			'sender'  =>$sender,
			'accepter'   =>$geter_id[$i],
			'content'    =>$content,
			'is_read'    =>0,
			'time'       =>$now
	    );
		
		$result=$pd->insert(array('data'=>$in_data,'table'=>'sys_news'));
	}
	/* echo $sender;
	echo "<br/>";
	echo $acceptname;
	echo "<br/>";
	echo $content;
	exit; */
	//$result=0;
	$tps='';
	/* if($id==0){
		$result=$pd->insert(array('data'=>$in_data,'table'=>'sys_news'));
		$tps='添加成功';
	}else{
		$result=$pd->update(array('data'=>$in_data,'table'=>'sys_news','where'=>"id=".$id));
		$tps='修改成功';
	} */
	if(empty($result)){
		$tips=array(
			'tips'=>'更新失败。',
			'url' =>'/?t=news_sys'
		);
		$tips=urlencode(serialize($tips));
		header('Location:/tips.php?gets='.$tips);
	}else{
		$tips=array(
			'tips'=>$tps,
			'url' =>'./?t=news_sys'
		);
		$tips=urlencode(serialize($tips));
		header('Location:/tips.php?gets='.$tips);
	}
}else{
	$tips=array(
		'tips'=>'不允许的表单提交方式，请按正常流程提交表单。',
		'url'=>'index.php'
	);
	$tips=urlencode(serialize($tips));
	header('Location:/tips.php?gets='.$tips);
}
?>